﻿using AssemblyVerifier;
using EmitDebugging.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Spackle.Testing;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;

namespace EmitDebugging.Tests.Extensions
{
	[TestClass]
	public sealed class MethodBaseExtensionsGetGenericParameterDeclarationNamesTests : CoreTests
	{
		[TestMethod]
		public void GetNamesFromMethodWithManyGenerics()
		{
			var names = this.GetType().GetMethod(
				"ManyGenerics").GetGenericParameterDeclarationNames();
			Assert.AreEqual(5, names.Count);
			Assert.IsTrue(names.Contains("T"));
			Assert.IsTrue(names.Contains("U"));
			Assert.IsTrue(names.Contains("V"));
			Assert.IsTrue(names.Contains("W"));
			Assert.IsTrue(names.Contains("X"));
		}

		[TestMethod]
		public void GetNamesFromMethodWithNoGenerics()
		{
			Assert.AreEqual(0, this.GetType().GetMethod(
				"NoGenerics").GetGenericParameterDeclarationNames().Count);
		}

		public void ManyGenerics<T, U, V, W, X>()
		{
		}

		public void NoGenerics()
		{
		}
	}
}
